pp108 : ontranslate Event

ontranslate Event


This event points to a function that will be executed each time before an element is getting translated.

Syntax

Inline HTML

<ELEMENT id=elementID translatable=true ontranslate="handler"...></ELEMENT>

Event property

elementID.ontranslate = handler


Parameters

Parameter

Description

isXhtml

Read-only. Boolean that contains one of the following values.

  • true - The translatable element is a pure XHTML.
  • false - The translatable element is not an XHTML.

language

Read-only. String that denotes the current language to which the element is to be translated.

value

Object that contains the XML reference of the value to be translated, which is retrieved from the dictionary. This value will contain an empty data inside it, if the language value is default, and if it does not contain any default translation value.


Remarks


Theontranslateattribute can be defined on any HTML element which contains the translatable attribute set to true.ontranslateshould contain the reference to a valid function name as in the above example. Developers can use this to change the values for the elements at run time.

Example

<!-- HTML definition for an HTML element --> <div translatable="true" ontranslate="changeItem">The color is Red</div> //Function called on ontranslate event of the translator. function changeItem(language, value, isXhtml) {    //Change the value. After change this will be the value always each time when a translation happens except for the default case    if (value) value.text = "The color is Green, always when translated"; }

See Also


translator